﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CarHelpDesk.Web.Models.Tag>" %>
 <% using (Ajax.BeginForm("EditQuestionTags", "Tags", new { questionID = ViewData["questionID"] }, new AjaxOptions()
       {
           HttpMethod = "POST",
           OnFailure = "onQuestionTagsEditFailure",
           OnSuccess = "onQuestionTagsEditSuccess",
           OnBegin = "onQuestionTagsEditBegin",
           OnComplete = "onQuestionTagsEditComplete"
       }, new { id = "submit_question_tag_edit" }))
    {%>   
<script type="text/javascript">
    $(document).ready(function() {
        $('.tags-edit-content').hide();
    });

    function showEditTagsMode() {
        $('.tags-edit-content').show('slow');
        $('.tags-content').hide();
        $('#edit_tags_link').hide();
    }

    function onQuestionTagsEditSuccess(content) {
        $('.tags-edit-content').hide('slow');
        $('.tags-content').html(content.get_object().Tags1);
        $('.tags-content').show();
        $('#edit_tags_link').show();
        $('#errorMessageNoRightTag').html("");
    }
    function onQuestionTagsEditFailure(content) {
        $('#errorMessageNoRightTag').html("Грешно въведен етикет.");
    }

    function onQuestionTagsEditBegin(content) {
        $("#submit_question_tag_edit").attr("disabled", true);
    }

    function onQuestionTagsEditComplete(content) {
        $("#submit_question_tag_edit").attr("disabled", false);
    }
</script>

<div class="tags-content">
<%=            ViewData["tableTags"]
%>

</div>
<% if (Context.User.IsInRole("JuniorModerator"))
      {%>
            <div class="float-right">  
                <b><a href="#" id="edit_tags_link" onclick="showEditTagsMode()">Промени етикетите на въпроса</a></b>
            </div>
            
         <div class="tags-edit-content">
         <%= Html.ValidationSummary()%>
         
            <div class="editor-label">
                Етикети:
            </div>
            <div class="editor-field">
            
               <%= Html.TextBox("Tags", ViewData["listTags"])%>
               <span id="errorMessageNoRightTag" style="color:Red"></span>
           </div>
           <input id="submit_question_tag_edit" type="submit" value="Промени" style="width:100px;"/> 
        </div>
            
            
   <% } %>
   
   
<% } %>

